from configparser import ConfigParser
import os
class ConRead:
    def __init__(self,fileName): # 需要读取的配置文件
        self.file = fileName
        # 把路径处理一下
        config_path = os.path.split(os.path.realpath(__file__))[0] + os.sep + fileName
        self.config = ConfigParser()
        self.config.read(config_path)
    def get_url_value(self,env): # 处理获取url地址公共方法
        if env == "base":
            return self.config.get("URL", "base_url")
        elif env == 'dev':
            return self.config.get("URL", "dev_url")
        elif env =='prod':
            return self.config.get("URL", "prod_url")
# if __name__ == '__main__':
    # print(os.path.split(os.path.realpath(__file__))[0] + os.sep + "config.ini")
   # D:\Users\Administrator\PycharmProjects\API_Auto\common\ConfigpaserRead.py
   #  print(os.path.realpath(__file__)) # D:\Users\Administrator\PycharmProjects\API_Auto\common\ConfigpaserRead.py
   #  print(os.path.split(os.path.realpath(__file__))[0] + os.sep + "config.ini") # 'D:\\Users\\Administrator\\PycharmProjects\\API_Auto\\common\'